Page({

  /**
   * 页面的初始数据
   */
  data: {
    user: [],
    money: '0.00',
    fwmoney: '0.00',
    number: '0',
    kouling: '请输入红包口令'
  },
  bindReward: function (event) {
    if (event.detail.value < 1) {
      this.setData({
        money: 1
      })
    } else {
      this.setData({
        money: event.detail.value
      })
    }
  },
  bindNumReward: function (event) {
    if (event.detail.value < 1) {
      this.setData({
        number: 1
      })
    } else {
      this.setData({
        number: event.detail.value
      })
    }
  },
  bindMoney: function (e) {
    this.setData({
      money: '',
    })
  },
  bindNum: function (e) {
    this.setData({
      number: '',
    })
  },
  bindKl: function (e) {
    this.setData({
      kouling: '',
    })
  },
  formSubmit: function (e) {
    var that = this;
    var formData = e.detail.value;
    if (formData.kouling == '') {
      wx.showModal({
        title: '提示',
        content: '口令未填写',
      })
    }
    if (formData.money < 1) {
      wx.showModal({
        title: '提示',
        content: '红包金额不正确'
      })
    }else if (formData.number < 1) {
      wx.showModal({
        title: '提示',
        content: '红包数量不正确',
      })
    }else if(formData.money/formData.number < 0.01){
      wx.showModal({
        title: '提示',
        content: '平均每个红包不能小于0.01',
      })
    }else{
      console.log("提交订单");
      //TODO 
      wx.navigateTo({
        url:"../index-lq/index"
      });
    }

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this;
    var value = wx.getStorageSync('user');
    if (value) {
      wx.getStorage({
        key: 'user',
        success: function (res) {
          console.log(res),
            that.setData({
              user: res.data
            })
        }
      })
    }
  }
})